package com.ly.lypopupwindowdemo.activity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import com.aspsine.swipetoloadlayout.OnRefreshListener;
import com.aspsine.swipetoloadlayout.SwipeToLoadLayout;
import com.ly.lypopupwindowdemo.R;

import butterknife.BindView;
import butterknife.ButterKnife;

import static android.R.attr.y;

public class PointActivity extends AppCompatActivity implements OnRefreshListener{
    SwipeToLoadLayout swipeToLoadLayout;

    private static final String TAG = "PointActivity";


    int y;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_point);
        ButterKnife.bind(this);

        findViewById(R.id.java).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                y = 6;
                changeint();
                String x = new String("goeasyway");
                StringBuilder sb  = new StringBuilder("goeasyway");
                change2(sb);
                change(x);
                //x = "even";
                System.out.println(x);
                Log.e(TAG, "onClick: =="+y );
                Log.e(TAG, "onClick: ==="+x);
                Log.e(TAG, "onClick: ==="+sb.toString() );
            }
        });

        swipeToLoadLayout = (SwipeToLoadLayout) findViewById(R.id.swipeToLoadLayout);
        swipeToLoadLayout.setOnRefreshListener(this);

        swipeToLoadLayout.post(new Runnable() {
            @Override
            public void run() {
                swipeToLoadLayout.setRefreshing(true);
            }
        });

    }

    private void changeint() {
        y=8;
    }

    private void change2(StringBuilder sb) {

        sb.append("even");
    }

    private void change(String x) {
        x = "even";
    }

    public void onWebView(View view){
        Intent intent = new Intent(this,TextActivity.class);
        intent.putExtra("state",0);
        startActivity(intent);
    }

    public void onWindowSoftInput(View view){
        Intent intent = new Intent(this,TextActivity.class);
        intent.putExtra("state",1);
        startActivity(intent);
    }

    public void cunchu(View view){
        Intent intent = new Intent(this,TextActivity.class);
        intent.putExtra("state",2);
        startActivity(intent);
    }


    @Override
    public void onRefresh() {
        swipeToLoadLayout.postDelayed(new Runnable() {
            @Override
            public void run() {
                swipeToLoadLayout.setRefreshing(false);
            }
        }, 3000);
    }
}
